﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Service.BAL;

namespace Service.DAL
{
    public class SanPham_DAL
    {
        public static List<SanPham_BAL> GetAll()
        {
            List<SanPham_BAL> result = new List<SanPham_BAL>();
            try
            {
                var sanPham = from sp in Common_DAL.StoreData.SanPhams
                              select new SanPham_BAL()
                              {
                                  MaSanPham = sp.MaSanPham,
                                  TenSanPham = sp.TenSanPham,
                                  SoLuong = (int)sp.SoLuongTrongKho,
                                  GiaBan = (float)sp.GiaBan
                              };
                result = sanPham.ToList<SanPham_BAL>();
            }
            catch
            {

            }
            return result;
        }
        public static List<SanPham_BAL> GetByCategory(string maloai)
        {
            List<SanPham_BAL> result = new List<SanPham_BAL>();
            var sanpham = from s in Common_DAL.StoreData.SanPhams
                          where (s.MaLoai == maloai)
                          select new SanPham_BAL()
                          {
                              MaSanPham = s.MaSanPham,
                              TenSanPham = s.TenSanPham,
                              SoLuong = (int)s.SoLuongTrongKho,
                              GiaBan = (float)s.GiaBan
                          };
            return sanpham.ToList<SanPham_BAL>();
        }
    }
}
